/*
 * FailExpectedTestResult.java  0.4.0 / Oct 25, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.nunit;

import junit.framework.Test;
import junit.framework.TestResult;

/**
 * TestResult that expects a failure or an error.
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public class FailExpectedTestResult extends TestResult {

// Private Fields. -------------------------------------------------------------

  private final TestResult testResult;

// Public Constructors. --------------------------------------------------------

  /**
   * Constructs new FailExpectedTestResult object.
   *
   * @param testResult the test result
   */
  public FailExpectedTestResult(TestResult testResult) {
    this.testResult = testResult;
  }

// Overridden Methods. ---------------------------------------------------------

  /**
   * {@inheritDoc}
   */
  public void startTest(Test test) {
    testResult.startTest(test);
  }

  /**
   * {@inheritDoc}
   */
  public void endTest(Test test) {
    if (wasSuccessful()) {
      testResult.addFailure(test, new TestNotFailed());
    }
    testResult.endTest(test);
  }

}
